/*
 * HttpTsMediaCaster.h
 *
 *  Created on: 2019年2月28日
 *      Author: terry
 */

#ifndef HTTPTSMEDIACASTER_H_
#define HTTPTSMEDIACASTER_H_

#include "BasicTsMediaCaster.h"
#include "TcpServer.h"


namespace av
{

class HttpTsMediaCaster : public BasicTsMediaCaster, public TcpServer
{
public:
    HttpTsMediaCaster();
    virtual ~HttpTsMediaCaster();

    virtual int open(const std::string& ip, uint16_t port, const MediaFormat& fmt);

    virtual void close();

    virtual bool isOpen();

    virtual void removeAllTarget();

protected:
    virtual void writePacket(uint8_t* data, int size, int64_t pts, int flags);

    virtual void writeMediaPacket(MediaPacketPtr& pkt);

protected:
    virtual TcpConnectionPtr create(evutil_socket_t fd);
    virtual void onClose(TcpConnectionPtr& conn);

protected:
    void closeAll();

    void dispatchPacket(TcpConnectionPtr& connection, MediaPacketPtr& pkt);

protected:


};

} /* namespace av */

#endif /* HTTPTSMEDIACASTER_H_ */
